package com.xwm93up.basic.lambdatips;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @Description: desc
 * @Author: xwm93up
 * @Since: 2021/12/2 15:26
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Student implements Comparable<Student>{
    private String name;
    private int age;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public int compareTo(Student s) {
        return name.compareTo(s.getName());
    }
    public static List<Student> getStudentList() {
        Student ram = new Student("Ram", 18);
        Student shyam = new Student("Shyam", 22);
        Student mohan = new Student("Mohan", 19);
        Student mahesh = new Student("Mahesh", 20);
        Student krishna = new Student("Krishna", 21);
        List<Student> students = Arrays.asList(ram, shyam, mohan, mahesh, krishna);
        return students;
    }
}
